import {ConfigEnv, UserConfig} from 'vite';
import path from 'path';
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

const pathResolve = (pathStr: string) => {
  return path.resolve(process.cwd(), pathStr);
};

export default ({ command, mode }: ConfigEnv): UserConfig => {

  console.log("command", command)
  console.log("mode", mode)

  return {
    // alias: {
    //   '/@/': pathResolve('./src'),
    // },
    resolve: {
      alias: [
        {
          // '/@/':
          find: /\/@\//,
          replacement: pathResolve('./src') + '/',
        },
        // /#/xxxx => types/xxxx
        {
          find: /\/#\//,
          replacement: pathResolve('./types') + '/',
        },
      ]

    },
    define: {
      'process.env': {}
    },
    // 配置 vite 的vue插件
    // 配置vite支持 jsx插件
    plugins: [vue(), vueJsx({})]
    // css: {
    //   preprocessorOptions: {
    //     sass: {
    //
    //     }
    //   }
    // }
  };
}

// module.exports = config;
